<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="D:\javaee\workspace\e9ding\WebContent\js\jquery-2.0.3.min.js">
</script>
</head>
<body>
<table>
<tr><td>苹果</td><td style="display:none" class="pronum" >1<td><input type="button" value="-" class="min" style="width: 20px;height: 20px;margin-left:15px;"/><input type="text" class="text_box" value="1" style="width: 20px;height: 15px"/><input type="button" class="add" value="+" style="width: 20px;height: 20px"/></td><td>20</td></tr>
<tr><td>苹果</td><td style="display:none" class="pronum" >1</td><td><input type="button" value="-" class="min" style="width: 20px;height: 20px;margin-left:15px;"/><input type="text" class="text_box" value="1" style="width: 20px;height: 15px"/><input type="button" class="add" value="+" style="width: 20px;height: 20px"/></td><td>20</td></tr>
<tr><td>苹果</td><td style="display:none" class="pronum" >1</td><td><input type="button" value="-" class="min" style="width: 20px;height: 20px;margin-left:15px;"/><input type="text" class="text_box" value="1" style="width: 20px;height: 15px"/><input type="button" class="add" value="+" style="width: 20px;height: 20px"/></td><td>20</td></tr>
</table>
<script type="text/javascript">
$(function () {
		$(".add", this).bind("click", function() {
			var t = $(this).parents("tr").find(".text_box");
			t.val(parseInt(t.val()) + 1)
			var changenum = $(this).parents("tr").find(".text_box").val();
		$(this).parents("tr").find(".pronum").text(changenum);
		var sum=0;
		var num1=0;
		var trs=document.getElementsByTagName("tr");
        //alert(trs.length);
		for(var i=0;i<trs.length;i++){
			var num=trs[i].childNodes[1].innerHTML;
		//	alert(num);
			var price=trs[i].childNodes[3].innerHTML;
			//alert(price);
			num1+=parseInt(num);
			sum+=parseFloat(price)*parseInt(num);
		}
		alert(sum);
		/* document.getElementById("pnum").innerHTML=num1;
		document.getElementById("money").innerHTML =sum; */
		})
		$(".min", this).bind("click", function() {
			var t = $(this).parents("tr").find(".text_box");
			if(t.val()>0){
				t.val(parseInt(t.val()) - 1)
				var changenum = $(this).parents("tr").find(".text_box").val();
				$(this).parents("tr").find(".pronum").text(changenum);
				var sum=0;
				var num1=0;
				var trs=document.getElementsByTagName("tr");
				for(var i=0;i<trs.length;i++){
					var num=trs[i].childNodes[1].innerHTML;
					//	alert(num);
						var price=trs[i].childNodes[3].innerHTML;
					num1+=parseInt(num);
					sum+=parseFloat(price)*parseInt(num);
				}
				/* document.getElementById("pnum").innerHTML=num1;
				document.getElementById("money").innerHTML =sum; */
			}
		})
	})
</script>
</body>
</html>